(Compound expressions allow you to control the order in which an expression is evaluated. A compound expression can also be used to group several expressions into what appears, from the point of view of surrounding expressions, as a single expression. Thus, you can use a compound expression anywhere a single expression would work. The result of evaluating a compound expression is the value of the last expression in the block, unless a specific exit or return value has been specified using a block control expression. See "Conditionals and Loops" on page 79, for information on using compound expressions with block control expressions such as
expression
expression
. . .
)
exit
and continue
.-- globals cannot be explicitly declared in a block
global m:0, n:1
-- a compound expression, because it is enclosed in parentheses
t := (if m < n then m else n)
0
(
x := "string1"
y := "string2"
print (x + y)
)
"string1string2"
OK
If the final statement in a compound expression is a local declaration, it returns undefined
rather that the value of the local declaration. Note the difference between the first and second expressions.
global y := (local x := 10)
undefined
global y := (x := 10)
-- ** Warning: Undeclared global x
10
This document is part of the ScriptX Language Guide, one of the volumes of the ScriptX Technical Reference Series. ScriptX is developed by the ScriptX Engineering Team at Apple Computer, successor to the Kaleida Engineering Team at Kaleida Labs, Inc.